package com.example.springboot.service;

import com.example.springboot.bean.Register;
import com.example.springboot.bean.User;
import com.example.springboot.repository.LoginRepository;
import com.example.springboot.repository.MailRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: supermarketparent
 * @description:
 * @author: MajorMKN
 * @create: 2019-10-26 16:57
 **/
@Service
public class LoginService implements LoginRepository {
    @Resource
    private LoginRepository loginRepository;
    @Resource
    private MailRepository mailRepository;


    public List<Register> findAll() {
        return loginRepository.findAll();
    }

    //手机登陆
    public List<Register> selectPhone(String phone) {
        return loginRepository.selectPhone(phone);
    }

    //普通登陆
    @Override
    public List<Register> selectName(String username) {
        return loginRepository.selectName(username);
    }

    @Override
    public int insertRegister(Register register) {
        return loginRepository.insertRegister(register);
    }

    /**
     * 用户注册，同时发送一封激活邮件
     */
    @Override
    public Register selectRegister(String username) {
        return loginRepository.selectRegister(username);
    }

//    /**
//     * 登录
//     * @param user
//     * @return
//     */
//    @Override
//    public User loginUser(User user) {
//        User user1 = loginRepository.loginUser(user);
//        if (user1 !=null){
//            return user1;
//        }
//        return null;
//    }

    /**
     * 根据激活码code进行查询用户，之后再进行修改状态
     * @param code
     * @return
     */
    @Override
    public Register checkCode(String code) {

        return loginRepository.checkCode(code);
    }
    /**
     * 激活账户，修改用户状态
     * @param register
     */
    @Override
    public void updateUserStatus(Register register) {
        loginRepository.updateUserStatus(register);
    }




}
